package com.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.entity.User;

public interface UserMapper {

    @Select("SELECT * FROM user")
    @Results({
    	@Result(property = "id",  column = "ID"),
    	@Result(property = "name",  column = "NAME"),
        @Result(property = "age", column = "AGE")
    })
    List<User> getAll();

    @Select("SELECT * FROM user WHERE id = #{id}")
    @Results({
        @Result(property = "name",  column = "name"),
        @Result(property = "age", column = "age")
    })
    User getOne(String id);

    @Insert("INSERT INTO user(ID,name,age) VALUES(#{id}, #{name}, #{age})")
    void insert(User user);

    @Update("UPDATE user SET NAME=#{name},AGE=#{age} WHERE id =#{id}")
    void update(User user);

    @Delete("DELETE FROM user WHERE id =#{id}")
    void delete(String id);

}
